/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javalens.gui;

import javalens.astronomy.Event;
import javalens.*;
import javalens.datageneration.FlatNoParallaxEventGenerator;
import javalens.datageneration.BinaryLensDataSetGenerator;
import javalens.datageneration.EventGenerator;
import javalens.datageneration.RegularLightCurveGenerator;
import javalens.datageneration.LightCurveGenerator;
import javalens.datageneration.DataSet;
import javalens.featurecalculators.PolyFitFeatureCalculator;
import javalens.featurecalculators.SingleLensAndResidualsFeatureCalculator;
import java.io.File;

/**
 *
 * @author vermaak
 */
public class CreateDataSetCommand implements Command {
    
    private int nCurves=0;

    public CreateDataSetCommand(int nCurves) {
        this.nCurves = nCurves;
    }
    
    
    public void execute() throws Exception {
          // event generator
        Event minimum = new Event(1.0e-5, 5, -20, 16);
        minimum.setF(0.75);
        minimum.setA(0.6);
        minimum.setAng(0);
        minimum.setQ(0.1);
        Event maximum = new Event(1.5, 50, 20, 22);
        maximum.setF(1.0);
        maximum.setA(1.7);
        maximum.setAng(360);
        maximum.setQ(1);
        EventGenerator eventGenerator = new FlatNoParallaxEventGenerator(minimum, maximum);
        // curve generator
        double startMinTe = -3;
        double startMaxTe = -2;
        double endMinTe = 2;
        double endMaxTe = 3;
        int nPoints = 200;
        LightCurveGenerator curveGenerator = new RegularLightCurveGenerator(startMinTe, startMaxTe, endMinTe, endMaxTe, nPoints);
        // calculator itself
        BinaryLensDataSetGenerator calculator = new BinaryLensDataSetGenerator(eventGenerator, curveGenerator,true);
        calculator.addFeatureCalculator(new PolyFitFeatureCalculator());
        calculator.addFeatureCalculator(new SingleLensAndResidualsFeatureCalculator());
        
        calculator.run(nCurves);
        DataSet result = calculator.getFeatures();
        result.toFile(new File("data1.csv"));
    }

}
